package com.devilvan.controller;

import com.devilvan.entity.Dept;
import com.devilvan.service.DeptClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@RestController
@RequestMapping("consumer")
public class FeignController{

    @Autowired
    private DeptClientService service;


    @GetMapping(value = "add" ,produces = "application/json; charset=UTF-8")
    public boolean add(Dept dept) {
        return service.addDept(dept);
    }

    @GetMapping(value = "get/{dept_id}", produces = "application/json; charset=UTF-8")
    public Dept get(@PathVariable("dept_id") Long dept_id) {
        return service.queryDeptById(dept_id);
    }

    @GetMapping(value = "get",produces = "application/json; charset=UTF-8")
    public List<Dept> get() {
        return service.queryAllDepts();
    }
}
